package com.bwei.mypaot.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

/**
 * Created by Administrator on 2017/1/4.
 */

public class MainLinearLayout extends RelativeLayout {
    //右边距
    int right;

    /**
     * 判断侧滑菜单是否为展开
     * true为关闭，false 为展开
     */
    boolean isClose=false;
    //判断是不是第一次进入的标记
    boolean isFirst=false;
    int x;
    int y;

    LinearLayout ll_right;
    MainLinearLayout ll_main;


    public void addrest(LinearLayout ll_right,MainLinearLayout ll_main){
        this.ll_right=ll_right;
        this.ll_main=ll_main;
    }

    public MainLinearLayout(Context context) {
        super(context);
    }

    public MainLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MainLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    public void RightClose(){

        if (isClose==false){
            //当isClose==false展开侧滑菜单
            isClose=true;
            Right(0);
        }else{
            isClose=false;
            Right(ll_right.getWidth());
        }


    }
    public void Right(int right){
        LayoutParams params = (LayoutParams) ll_right.getLayoutParams();
        params.rightMargin = right;
        ll_right.setLayoutParams(params);


        LayoutParams params1= (LayoutParams) ll_main.getLayoutParams();
        params1.rightMargin=(ll_right.getWidth()-Math.abs(right));
        ll_main.setLayoutParams(params1);
    }



}
